package com.kxmall.web.controller.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.kxmall.common.core.page.TableDataInfo;
import com.kxmall.group.domain.KxGroupShop;
import com.kxmall.group.domain.vo.KxGroupShopVo;
import com.kxmall.group.mapper.KxGroupShopMapper;
import com.kxmall.web.controller.order.service.IKxAppGroupService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author kaixin
 * @version 1.0
 * @date 2023/9/6
 */

@RequiredArgsConstructor
@Service
public class KxAppGroupService implements IKxAppGroupService {


    private final KxGroupShopMapper baseMapper;

    @Override
    public TableDataInfo<KxGroupShopVo> getGroupShopPage(Long storageId, Integer pageNo, Integer pageSize) {
        Long count = baseMapper.selectCount(new LambdaQueryWrapper<KxGroupShop>()
                .eq(KxGroupShop::getStorageId, storageId)
                .eq(KxGroupShop::getStatus,1));
        List<KxGroupShopVo> groupShopPage = baseMapper.getGroupShopPage(storageId,(pageNo - 1) * pageSize, pageSize);
        return  new TableDataInfo<>(groupShopPage, count);
    }
}
